package com.ruoyi.pcj.interfaces.app;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.pcj.domain.*;
import com.ruoyi.pcj.dto.friend.FriendListDto;
import com.ruoyi.pcj.dto.friend.FriendSessionDto;
import com.ruoyi.pcj.service.*;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.MapUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 好友相关接口
 */
@AllArgsConstructor
@RestController
@RequestMapping("/wx/friends")
public class FriendsController {

    private IPcjLtFriendSettingService friendSettingService;

    private IPcjLtFriendRecordsService friendRecordsService;

//    /**
//     * 添加好友
//     *
//     * @param params {"friendId":"朋友id"}
//     * @return
//     */
//    @PostMapping("/addFriend")
//    public AjaxResult addFriend(@RequestBody Map<String, Object> params) {
//        PcjLtFriendList friend = friendListService.addFriend(MapUtils.getLong(params, "friendId"));
//        return AjaxResult.ok(friend);
//    }

    /**
     * 好友聊天
     *
     * @param params {"friendId":"朋友id",content:"聊天内容","contentType":"0-文字,1-文件，2-图片，3-音频"}
     * @return
     */
    @PostMapping("/chat")
    public AjaxResult chat(@RequestBody Map<String, Object> params) {
        PcjLtFriendRecords records = friendRecordsService.chat(params);
        return AjaxResult.ok(records);
    }


    /**
     * 获取好友列表
     *
     * @return
     */
    @PostMapping("/getFriendList")
    public AjaxResult getFriendList() {
        List<FriendListDto> friendList = friendSettingService.getFriendList();
        return AjaxResult.ok(friendList);
    }

    /**
     * 获取聊天会话
     *
     * @return
     */
    @PostMapping("/getChatSession")
    public AjaxResult getChatSession() {
        List<FriendSessionDto> friendList = friendSettingService.getChatSession();
        return AjaxResult.ok(friendList);
    }


}
